<?php
/**
 * Created by PhpStorm.
 * User: mars
 * Date: 2018/8/14
 * Time: 下午3:21
 */

namespace backend\models;


use common\models\Photostatus;
use common\helpers\Util;
use yii\helpers\Url;


class Photo  extends \common\models\Photo {

//	public $authorName;

	public function illegal(){
		$this->status = 3;
		return ($this->save()?true:false);
	}


	public function beforeSave( $insert ) {
		Util::handleImgUpload($this, 'img', $insert, '@photo', []);

		if(parent::beforeSave($insert)){

			if ($insert){
				$this->status = 1; //设置默认状态为正常
				$this->created_at = date('Y-m-d H:i:s');
				$this->updated_at = date('Y-m-d H:i:s');
			}
			else{
				$this->updated_at = date('Y-m-d H:i:s');
			}
			return true;

		}else{
			return false;
		}
	}



//	public function beforeSave($insert)
//	{
//		Util::handleModelSingleFileUpload($this, 'thumb', $insert, '@thumb', ['thumbSizes'=>self::$thumbSizes]); //储存图片
//		$this->seo_keywords = str_replace('，', ',', $this->seo_keywords);
//		if ($insert) {
//			$this->author_id = yii::$app->getUser()->getIdentity()->getId();
//			$this->author_name = yii::$app->getUser()->getIdentity()->username;
//		}
//		return parent::beforeSave($insert);
//	}


}